import 'package:color_dart/RgbaColor.dart';
import 'package:flutter/material.dart';
import 'package:im_flutter_sdk_example/jsonserialize/active/data.dart';
import 'package:im_flutter_sdk_example/utils/constants.dart';
import 'package:im_flutter_sdk_example/utils/global.dart';

class MainPage extends StatelessWidget {
  final ActiveData item;
  const MainPage({Key key, this.item}) : super(key: key);
  Widget space(Widget child) {
    return Container(
      margin: EdgeInsets.only(right: 6),
      child: child,
    );
  }

  @override
  Widget build(BuildContext context) {
    return Container(
      padding: EdgeInsets.symmetric(vertical: 10, horizontal: 16),
      decoration: BoxDecoration(
          color: Colors.white,
          borderRadius: BorderRadius.only(
              topLeft: Radius.circular(20), topRight: Radius.circular(20))),
      child: Column(
        crossAxisAlignment: CrossAxisAlignment.start,
        children: [
          Container(
            width: G.screenWidth(),
            child:
                Column(crossAxisAlignment: CrossAxisAlignment.start, children: [
              Text('${item.activitiesTopic}',
                  style: TextStyle(
                      color: rgba(68, 68, 68, 1),
                      fontSize: 17,
                      fontWeight: FontWeight.bold)),
            ]),
          ),
          item.isFee == 1
              ? Row(
                  crossAxisAlignment: CrossAxisAlignment.baseline,
                  children: [
                    Padding(
                      padding: EdgeInsets.only(right: 4),
                      child: Text(
                        '¥',
                        style: TextStyle(
                          color: rgba(235, 101, 13, 1),
                          fontSize: 11,
                        ),
                      ),
                    ),
                    Text(
                      '${item.regFee}',
                      style: TextStyle(
                          color: rgba(235, 101, 13, 1),
                          fontSize: 16,
                          fontWeight: FontWeight.bold),
                    ),
                  ],
                )
              : Row(
                  crossAxisAlignment: CrossAxisAlignment.baseline,
                  children: [
                    Text(
                      '免费',
                      style: TextStyle(
                        color: rgba(235, 101, 13, 1),
                        fontSize: 16,
                      ),
                    ),
                  ],
                ),
          Container(
            padding: EdgeInsets.fromLTRB(0, 6, 0, 16),
            color: Colors.white,
            child: Column(
              crossAxisAlignment: CrossAxisAlignment.start,
              children: [
                buildInfo('${item.startTime} - ${item.endTime}',
                    'lib/assets/images/label/label_time.png'),
                buildInfo('${item.address}',
                    'lib/assets/images/label/label_position.png'),
                buildInfo(
                    '人工智能、云计算、医疗', 'lib/assets/images/label/label_active.png'),
                Divider(
                  height: 10.0,
                  indent: 0.0,
                  color: rgba(235, 235, 235, 1),
                ),
                Container(
                    margin: EdgeInsets.fromLTRB(0, 12, 0, 6),
                    child: Text('主办方', style: mainTitleStyle)),
                Padding(
                  padding: const EdgeInsets.symmetric(vertical: 4),
                  child: Text('上海辉科展览服务有限公司', style: subtitleStyle),
                ),
                Padding(
                  padding: const EdgeInsets.symmetric(vertical: 4),
                  child: Text('中科淮北技术产业研究院', style: subtitleStyle),
                ),
                Container(
                    margin: EdgeInsets.only(bottom: 16),
                    child: Text('协办方', style: mainTitleStyle)),
                Text('国仟创业投资管理（苏州）有限公司', style: subtitleStyle),
              ],
            ),
          ),
        ],
      ),
    );
  }

  Widget buildInfo(String title, String src) {
    return Container(
      color: Colors.white,
      padding: EdgeInsets.only(bottom: 12, right: 16),
      child: Row(
        mainAxisAlignment: MainAxisAlignment.start,
        children: [
          SizedBox(
            width: 12,
            height: 12,
            child: Image.asset(
              '$src',
              fit: BoxFit.contain,
            ),
          ),
          Container(
              child: Text('$title',
                  style: TextStyle(color: rgba(68, 68, 68, 1), fontSize: 14)),
              margin: EdgeInsets.only(left: 6)),
        ],
      ),
    );
  }
}
